package com.idanchuang.component.logback.filter;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import com.idanchuang.component.core.helper.EnvContext;
import com.idanchuang.component.logback.converter.TraceIdPatternConverter;

/**
 *
 * 标准输出过滤, 本地输出 , 容器环境不输出
 *
 * @author yjy
 * @date 2020/9/1 10:20
 **/
public class ConsoleLogFilter extends Filter<ILoggingEvent> {

    private final static String ENV_KEY = "ACG_CLUSTER";
    private final static String ENV_VALUE_K8S = "K8S";

    @Override
    public FilterReply decide(ILoggingEvent iLoggingEvent) {
        String currentEnv = System.getenv(ENV_KEY);
        return ENV_VALUE_K8S.equals(currentEnv) ? FilterReply.DENY : FilterReply.NEUTRAL;
    }

}
